package com.codeduck.test.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codeduck.test.entity.AlarmInfo;
import com.codeduck.test.mapper.AlarmInfoMapper;
import com.codeduck.test.service.AlarmInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: <a href="mailto:codeduck@163.com">codeduck</a>
 * @date: 2022/10/26
 */
@Service
public class AlarmInfoServiceImpl extends ServiceImpl<AlarmInfoMapper, AlarmInfo> implements AlarmInfoService {

    @Resource
    private AlarmInfoMapper alarmInfoMapper;

    @Override
    public boolean batchDelete(List<AlarmInfo> alarmInfoList) {
        List<String> ids = alarmInfoList.stream().map(AlarmInfo::getAlarmId).collect(Collectors.toList());
        return this.removeByIds(ids);
    }

    @Override
    public List<AlarmInfo> getAlarmInfoList(int current, int size) {
        return alarmInfoMapper.getList(current, size);
    }
}
